package com.boyi.center.service.fallback;

import com.boyi.center.service.UserService;
import com.boyi.db.entity.User;
import com.boyi.shared.common.Message;
import com.boyi.shared.common.R;
import com.boyi.shared.common.Result;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * UserServiceFallbackFactory.class
 * 服务的降级
 * @author tingwen
 * @date date
 */
@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public Result<List<User>> save(User entity) {
                return null;
            }

            @Override
            public Result<List<User>> batchInsert(List<User> entities) {
                return null;
            }

            @Override
            public Result<List<User>> batchDeleteByPrimaryKeys(Object[] keys) {
                return null;
            }

            @Override
            public Result<List<User>> deleteByPrimaryKey(Object key) {
                return null;
            }

            @Override
            public Result<List<User>> updateByPrimaryKey(User entity) {
                return null;
            }

            @Override
            public Result<List<User>> updateByPrimaryKeySelective(User entity) {
                return null;
            }

            @Override
            public Result<List<User>> selectByPrimaryKey(Object key) {
                return null;
            }

            @Override
            public Result<List<User>> selectByExample(Object example) {
                return null;
            }

            @Override
            public Result<List<User>> select(User entity) {
                return R.message(Message.AUTHENTICATION_ERROR);
            }

            @Override
            public Result<List<User>> selectPageByExample(User user, int pageNum, int pageSize) {
                return null;
            }

            @Override
            public boolean isSuccess(int flag) {
                return false;
            }

            @Override
            public boolean isExist(User entity) {
                return false;
            }

            @Override
            public int count(User user) {
                return 0;
            }
        };
    }
}
